package com.xzzz.irda.registry.service;

import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties;
import org.springframework.cloud.client.serviceregistry.ServiceRegistry;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

@Configuration
public class RedisServiceConfiguration {

    @Bean
    public RedisRegistration redisRegistration() {
        return new RedisRegistration();
    }

    @Bean
    public ServiceRegistry<RedisRegistration> serviceRegistry(StringRedisTemplate redisTemplate) {
        return new RedisServiceRegistry(redisTemplate);
    }

    @Bean
    public RedisAutoServiceRegistration redisAutoServiceRegistration(ServiceRegistry<RedisRegistration> serviceRegistry,
                                                                     AutoServiceRegistrationProperties properties,
                                                                     RedisRegistration registration) {
        return new RedisAutoServiceRegistration(serviceRegistry, properties, registration);
    }
}
